<template>
  <div class="top">
    <h1>教得慧-智慧大脑管理中心</h1>
    <!-- <p class="top_p">{{name}}</p> -->
    <div class="rightActionBtn">
      <p>{{nickname}}</p>
      <el-button @click="logout">退出登录</el-button>
    </div>
    <p class="nav">
      <router-link
        v-for="(item) in listed"
        :key="item.value"
        :to="{path:item.path}"
        class="topbar-item"
      >{{item.label}}</router-link>
    </p>
  </div>
</template>

<script>
let school_name = window.sessionStorage.getItem('school_name')
export default {
  //name: 'nav',
  data() {
    return {
      listed: [
        {
          path: '/index',
          label: '整体概况',
        },
        {
          path: '/activity',
          label: '用户活跃度',
        },
        {
          path: '/prepare',
          label: '备课情况',
        },
        {
          path: '/lecture',
          label: '授课情况',
        },
        {
          path: '/resources',
          label: '资源包审核',
        },
      ],
      name: '',
      nickname: localStorage.getItem('nickname'),
    }
  },
  mounted() {
    var self = this
    self.name = school_name
  },
  methods: {
    logout() {
      //退出登录 移除token
      sessionStorage.removeItem('token')
      sessionStorage.removeItem('school_name')

      this.$router.replace('/')
      setTimeout(() => {
        this.$message.success('退出成功！')
      }, 1000)
    },
  },
}
</script>

<style>
.top h1 {
  font-size: 34px;
  font-weight: 800;
  line-height: 48px;
  color: #fff;
  text-shadow: 0px 3px 3px rgba(0, 0, 0, 0.16);
  text-align: center;
  padding: 14px 0 8px 0;
}

.top_p {
  font-size: 26px;
  font-weight: 800;
  line-height: 37px;
  color: #fff;
  text-shadow: 0px 3px 3px rgba(0, 0, 0, 0.16);
  text-align: center;
}

.top .nav {
  background: #fff;
  height: 53px;
  line-height: 53px;
  padding-left: 30px;
  margin-top: 14px;
}

.top a {
  display: inline-block;
  margin-right: 52px;
  font-size: 14px;
  font-weight: 400;
  color: #000000;
}

.top .nav .router-link-exact-active {
  color: #55e4c2;
  position: relative;
}

.top .nav .router-link-exact-active::after {
  content: '';
  width: 100%;
  height: 2px;
  background: #55e4c2;
  position: absolute;
  bottom: 0;
  left: 0;
}
.rightActionBtn {
  float: right;

  margin-top: -48px;
  margin-right: 140px;
  display: flex;
  align-items: center;
  font-size: 24px;
  color: #fff;
}
.rightActionBtn button {
  background: transparent;
  color: #fff;
  margin-left: 20px;
}
</style>
